from starlette.endpoints import HTTPEndpoint
from starlette.responses import JSONResponse

from database import Session, engine
import datetime
from dao import DaoPendingProRep
from dao import DaoWorkRecord


class PendingProRep(HTTPEndpoint):

    async def get(self, request):
        session = Session()
        try:
           bureauid = request.query_params["bureauid"]
           flag = request.query_params["flag"]
           return  DaoPendingProRep.get_pending_pro_rep(session, bureauid, flag)
        finally:
            session.close()

class PendingProRepDetail(HTTPEndpoint):

    async def get(self, request):
        session = Session()
        try:
            bureauid = request.query_params["bureauid"]
            flag = request.query_params["flag"]
            stationid = request.query_params["stationid"]
            return DaoWorkRecord.get_pending_pro_detail(session, bureauid, stationid, flag)
        finally:
            session.close()